from enum import Enum
from typing import List, Optional
from datetime import datetime, date
from pydantic import BaseModel


class User(BaseModel):
    uuid: str = None
    username: str = None
    password: str = None
    gender: str = '0'
    head_sculpture: str = None
    nickname: str = None
    full_name: str = None
    birthday: str = None
    # email: Optional[EmailStr] = None
    email: str = None
    profile: str = None
    key: str = None
    is_active: bool = 1
    occupation: str = None
    company: str = None
    company_address: str = None
    tech_label: str = None
    hobby_tag: str = None
    contact_address: str = None
    phone: Optional[str] = None
    remark: str = None
    last_login_time: datetime = None
    create_time: datetime = None
    update_time: datetime = None

    class Config:
        orm_mode = True


class Password(BaseModel):
    username: str
    old_passwd: str
    # 新密码
    new_passwd: str
    # 确认新密码
    confirm_password: str

    class Config:
        orm_mode = True


class Company(BaseModel):
    bid: str = None
    company_name: str = None
    city: str = None
    country: str = None
    country_iso_code: str = None
    company_local_name: str = None

    class Config:
        orm_mode = True


class Gender(Enum):
    male = '男'
    female = '女'


class Report(BaseModel):
    pid: str

    class Config:
        orm_mode = True


class Token(BaseModel):
    access_token: str
    token_type: str


class TokenData(BaseModel):
    username: str = None
    scopes: List[str] = []


class UserPermission(BaseModel):
    username: str = None
    scopesname: str = None
    path: str = None
    description: str = None
    user_uuid: str = None
    is_active: str = None
    scopesgroup: str = None

    class Config:
        orm_mode = True


class APISource(BaseModel):
    aid: str = None
    apply_name: str = None
    cate_name: str = None
    cid: str = None
    # api描述
    description: str = None
    # 用来区别是公司还是个人用户
    user_check: str = '0'
    # 提示，比如"本接口仅支持企业用户，企业认证后才能调用"
    limit_remark: str = None
    api_image: str = None
    # 预留字段，暂无意义
    is_active: Optional[bool] = 0


class UserApiKey(BaseModel):
    # username: str = None
    # apply_name: str = None
    apply_id: str = None
    # path: str = None
    # description: str = None
    is_active: Optional[bool] = None

    class Config:
        orm_mode = True


class UserVerify(BaseModel):
    username: str = None
    password: str = None

    class Config:
        orm_mode = True


class TokenCertify(BaseModel):
    token: str = None

    class Config:
        orm_mode = True


class Billing(BaseModel):
    username: str
    aid: str
    api: str = None
    result: int
    user_uuid: str = None
    remark: str = None

    class Config:
        orm_mode = True
